package com.bestsoft.web.controller.baseinfo;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bestsoft.common.annotation.Log;
import com.bestsoft.common.core.controller.BaseController;
import com.bestsoft.common.core.domain.AjaxResult;
import com.bestsoft.common.enums.BusinessType;
import com.bestsoft.baseinfo.domain.BaseInfoClient;
import com.bestsoft.baseinfo.service.IBaseInfoClientService;
import com.bestsoft.common.utils.poi.ExcelUtil;
import com.bestsoft.common.core.page.TableDataInfo;

/**
 * 客户资料Controller
 * 
 * @author1 王识宇
 * @date 2023-09-19
 */
@RestController
@RequestMapping("/domain/client")
public class BaseInfoClientController extends BaseController
{
    @Autowired
    private IBaseInfoClientService baseInfoClientDocService;

    /**
     * 查询客户资料列表
     */
    @PreAuthorize("@ss.hasPermi('domain:client:list')")
    @GetMapping("/list")
    public TableDataInfo list(BaseInfoClient baseInfoClientDoc)
    {
        startPage();
        List<BaseInfoClient> list = baseInfoClientDocService.selectBaseInfoClientDocList(baseInfoClientDoc);
        return getDataTable(list);
    }

    /**
     * 导出客户资料列表
     */
    @PreAuthorize("@ss.hasPermi('domain:client:export')")
    @Log(title = "客户资料", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BaseInfoClient BaseInfoClientDoc)
    {
        List<BaseInfoClient> list = baseInfoClientDocService.selectBaseInfoClientDocList(BaseInfoClientDoc);
        ExcelUtil<BaseInfoClient> util = new ExcelUtil<BaseInfoClient>(BaseInfoClient.class);
        util.exportExcel(response, list, "客户资料数据");
    }

    /**
     * 获取客户资料详细信息
     */
    @PreAuthorize("@ss.hasPermi('domain:client:query')")
    @GetMapping(value = "/{clientid}")
    public AjaxResult getInfo(@PathVariable("clientid") Long clientid)
    {
        return success(baseInfoClientDocService.selectBaseInfoClientDocByClientid(clientid));
    }

    /**
     * 新增客户资料
     */
    @PreAuthorize("@ss.hasPermi('domain:client:add')")
    @Log(title = "客户资料", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BaseInfoClient baseInfoClientDoc)
    {
        return toAjax(baseInfoClientDocService.insertBaseInfoClientDoc(baseInfoClientDoc));
    }

    /**
     * 修改客户资料
     */
    @PreAuthorize("@ss.hasPermi('domain:client:edit')")
    @Log(title = "客户资料", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BaseInfoClient baseInfoClientDoc)
    {
        return toAjax(baseInfoClientDocService.updateBaseInfoClientDoc(baseInfoClientDoc));
    }

    /**
     * 删除客户资料
     */
    @PreAuthorize("@ss.hasPermi('domain:client:remove')")
    @Log(title = "客户资料", businessType = BusinessType.DELETE)
	@DeleteMapping("/{clientids}")
    public AjaxResult remove(@PathVariable Long[] clientids)
    {
        return toAjax(baseInfoClientDocService.deleteBaseInfoClientDocByClientids(clientids));
    }
}
